package pl.koziolekweb.szkola.GFPolskieZnaki;

// GF-PolskieZnaki/Main.java
 
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import static javax.swing.SwingConstants.RIGHT;

public class Main {

    static char[] znM = { '\u0105', '\u0107', '\u0119',
                          '\u0142', '\u0144', '\u00f3',
                          '\u015b', '\u017a', '\u017c'
                        };
    static char[] znD = { '\u0104', '\u0106', '\u0118',
                          '\u0141', '\u0143', '\u00d3',
                          '\u015a', '\u0179', '\u017b'
                        };

    public static void main(String[] args) {
        new Main();
    }

    Main() {
        final JFrame f = new JFrame("\u0104\u0106\u0118" +
                  "\u0141\u0143\u00d3\u015a\u0179\u017b");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel pan = new MyPanel();
        pan.setLayout(new GridLayout(znM.length,4,10,5));
        pan.setBorder(BorderFactory.
            createEmptyBorder(10,0,10,40));

        for (int i =0; i < znM.length; ++i) {
            pan.add(new JLabel(""+znM[i],RIGHT));
            pan.add(new JLabel("\\u" +
                String.format("%04X",(int)znM[i])));
            pan.add(new JLabel(""+znD[i],RIGHT));
            pan.add(new JLabel("\\u" +
                String.format("%04X",(int)znD[i])));
        }
        f.add(pan);

        SwingUtilities.invokeLater( new Runnable() {
            public void run() {
                f.pack();
                Dimension scr =
                    Toolkit.getDefaultToolkit().
                                getScreenSize();
                f.setLocation(
                    (scr.width -f.getWidth() )/2,
                    (scr.height-f.getHeight())/2
                );
                f.setVisible(true);
            }
        });
    }
}
